New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow tests to run with isolated stores #6743
Allow tests to run with isolated stores #6743
Conversation
06685b4
to
d10c58a
Compare
Also, add a decorator to explicitly use an empty store for a block of code. Each unique scheduler will have a unique store. This will be important soon, as I'm about to add tests for caching of file downloads which relies on the in-store state.
d10c58a
to
66df8dc
Compare
@@ -100,6 +101,7 @@ def create_scheduler(rules, validate=True, native=None): | |||
native, | |||
FileSystemProjectTree(os.getcwd()), | |||
'./.pants.d', | |||
safe_mkdtemp(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See my comment on the other review.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think isolation by default is good, because:
- Isolation is generally good. I think @dotordogh or I ran into issues where
pants/tests/python/pants_test/engine/test_fs.py
Lines 406 to 423 in db713e4
def test_materialize_directories(self): # I tried passing in the digest of a file, but it didn't make it to the # rust code due to all of the checks we have in place (which is probably a good thing). self.prime_store_with_roland_digest() with temporary_dir() as temp_dir: dir_path = os.path.join(temp_dir, "containing_roland") digest = Digest( text_type("63949aa823baf765eff07b946050d76ec0033144c785a94d3ebd82baa931cd16"), 80 ) scheduler = self.mk_scheduler(rules=create_fs_rules()) scheduler.materialize_directories((DirectoryToMaterialize(text_type(dir_path), digest),)) created_file = os.path.join(dir_path, "roland") with open(created_file, 'r') as f: content = f.read() self.assertEqual(content, "European Burmese") prime_store_with_roland_digest
was added, because it relied on the store already happening to have the digest in question in it. - The speedup of re-using an existing store should be pretty small.
(The "force isolation" function is handy because the default in this PR is actually to share a store across an test class)
Happy to re-visit if you are convinced otherwise :)
Also, add a decorator to explicitly use an empty store for a block of code. Each unique scheduler will have a unique store. This will be important soon, as I'm about to add tests for caching of file downloads which relies on the in-store state.
Also, add a decorator to explicitly use an empty store for a block of
code.
Each unique scheduler will have a unique store. This will be important
soon, as I'm about to add tests for caching of file downloads which
relies on the in-store state.